package com.pounds.control;

import com.pounds.pojo.Car;
import com.pounds.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("car/car_info")
public class CarControl {

    @Autowired
    private CarService carService;

    @GetMapping("all_car")
    public List<Car> getAllCar() {
        return carService.getAllCar();
    }

    @GetMapping("new_car")
    public String addCar(String account,String name,String type,String level,String country,String power,String price){
        return carService.addCar(account, name, type, level, country, power, price);
    }

    @GetMapping("user_car")
    public List<Car> getUserCar(String account) {
        return carService.getUserCar(account);
    }

    @PostMapping("del_car")
    public void deleteCar(int id){
        carService.deleteCar(id);
    }
}
